package com.cdut.hwadeefsc.mapper;

import com.cdut.hwadeefsc.entity.awards;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface awardsMapper {
    @Select("SELECT * FROM awards WHERE student_id = #{studentId} ORDER BY created_at DESC")
    List<awards> findByStudentId(Integer studentId);

    @Insert("INSERT INTO awards (student_id, external_student_no, description, type, issued_by, issued_at, created_at)" +
            "VALUES (#{studentId}, #{externalStudentNo}, #{description}, #{type}, #{issuedBy},  #{issuedAt}, #{createdAt})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insert(awards award);

    @Delete("DELETE FROM awards WHERE id = #{id}")
    int delete(Integer id);
}




